<?php

class Zhishidi_Express_Block_Adminhtml_Type_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

    protected function _prepareForm() {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('expressTypeFieldset', array('legend' => Mage::helper('zhishidi_express')->__("Express Type information")));

        $fieldset->addField('type_code', 'text', array(
            'name' => 'type_code',
            'label' => Mage::helper('zhishidi_express')->__('Type Code'),
            'title' => Mage::helper('zhishidi_express')->__('Type Code'),
             'required' => true,
        ));


        $fieldset->addField('type_name', 'text', array(
            'name' => 'type_name',
            'label' => Mage::helper('zhishidi_express')->__('Type Name'),
            'title' => Mage::helper('zhishidi_express')->__('Type Name'),
            'class' => 'required-entry',
            'required' => true,
        ));


        $fieldset->addField('type_discount', 'text', array(
            'name' => 'type_discount',
            'label' => Mage::helper('zhishidi_express')->__('Discount'),
            'title' => Mage::helper('zhishidi_express')->__('Discount'),           
            'required' => false,
            'style' => 'width:50px;',
        ));

        $fieldset->addField('type_surcharge', 'text', array(
            'name' => 'type_surcharge',
            'label' => Mage::helper('zhishidi_express')->__('Surcharge'),
            'title' => Mage::helper('zhishidi_express')->__('Surcharge'),
            'required' => false,
             'style' => 'width:50px;',
        ));




        $fieldset->addField('type_weight_unit', 'text', array(
            'name' => 'type_weight_unit',
            'label' =>  Mage::helper('zhishidi_express')->__('Weight Unit (g)'),
            'title' =>  Mage::helper('zhishidi_express')->__('Weight Unit (g)'),
            'required' => true,
             'style' => 'width:100px;',
        ));


        $fieldset->addField('type_max_weight', 'text', array(
            'name' => 'type_max_weight',
            'label' =>  Mage::helper('zhishidi_express')->__('Max Weight (g)'),
            'title' =>  Mage::helper('zhishidi_express')->__('Max Weight (g)'),
            'required' => false,
             'style' => 'width:100px;',
        ));

     

         $fieldset->addField('type_handle', 'select', array(
            'name' => 'type_handle',
            'label' => Mage::helper('zhishidi_express')->__('Handle Type'),
            'title' => Mage::helper('zhishidi_express')->__('Handle Type'),
            'required' => true,
            'values' => array(
                array(
                    'value' => 'fixed',
                    'label' => Mage::helper('zhishidi_express')->__('Fixed'),
                ),
                array(
                    'value' => 'table_rate',
                    'label' => Mage::helper('zhishidi_express')->__('Table Rate'),
                ),
                array(
                    'value' => 'fixed_table_rate',
                    'label' => Mage::helper('zhishidi_express')->__('Fixed And Table Rate'),
                )


            ),
        ));

         $fieldset->addField('type_sep_weight', 'text', array(
            'name' => 'type_sep_weight',
            'label' =>  Mage::helper('zhishidi_express')->__('Separate Weight (g)'),
            'title' =>  Mage::helper('zhishidi_express')->__('Separate Weight (g)'),
            'required' => false,
             'style' => 'width:100px;',
        ));

         $fieldset->addField('type_sep_weight_unit', 'text', array(
            'name' => 'type_sep_weight_unit',
            'label' =>  Mage::helper('zhishidi_express')->__('Separate Weight Unit (g)'),
            'title' =>  Mage::helper('zhishidi_express')->__('Separate Weight Unit (g)'),
            'required' => false,
             'style' => 'width:100px;',
        ));

 

        $groupCollection = Mage::getModel('zhishidi_express/group')->getCollection();
        $groupArray = array();
       
        array_unshift($groupArray, array());
        foreach ($groupCollection as $group) {
            $groupArray[] = array(
                'value' => $group->getId(),
                'label' => $group->getGroupName(),
            );
        }
        $fieldset->addField('type_sep_group', 'select', array(
            'name' => 'type_sep_group',
            'label' => Mage::helper('zhishidi_express')->__('Separate Zone Group'),
            'title' => Mage::helper('zhishidi_express')->__('Separate Zone Group'),
            'values' => $groupArray,
        ));


        $fieldset->addField('type_note', 'textarea', array(
            'name' => 'type_note',
            'label' => Mage::helper('zhishidi_express')->__('Type Note'),
            'title' => Mage::helper('zhishidi_express')->__('Type Note'),
            'required' => false,
        ));

        $fieldset->addField('type_status', 'select', array(
            'name' => 'type_status',
            'label' => Mage::helper('zhishidi_express')->__('Status'),
            'title' => Mage::helper('zhishidi_express')->__('Status'),
            'required' => true,
            'values' => array(
                array(
                    'value' => 'public',
                    'label' => Mage::helper('zhishidi_express')->__('Public'),
                ),
                array(
                    'value' => 'hidden',
                    'label' => Mage::helper('zhishidi_express')->__('Hidden'),
                )
            ),
        ));

        if (Mage::getSingleton('adminhtml/session')->getExpressTypeData()) {
            $form->setValues(Mage::getSingleton('adminhtml/session')->getExpressTypeData());
            Mage::getSingleton('adminhtml/session')->setExpressTypeData(null);
        } elseif (Mage::registry('express_type_data')) {
            $form->setValues(Mage::registry('express_type_data')->getData());
        }
        return parent::_prepareForm();
    }

}